Switching to iwd from network manager
Details
We are going to need iwd
network managers. But by default DHCP client is
disabled and requires a external DHCP client. We are going to use dhcpcd5
.
For resolving DNS will fail because there is no local DNS server. We are going
to use systemd-resolved
for this purpose.
Pre-requisites
- Install
iwd
anddhcpcd5
sudo apt install iwd dhcpcd5
- Disable
NetworkManager
,dnsmasq
andresolvconf
services:
sudo systemctl disable NetworkManager
sudo systemctl disable dnsmasq
sudo systemctl disable resolvconf
- Configure the DHCP server, disable ip configuration for unwanted interfaces and set a static IP address for the main interface:
# /etc/dhcpcd.conf
denyinterfaces wlan0
interface wlan1
static ip_address=192.168.1.111/24
static routers=192.168.1.1
static domain_name_servers=192.168.1.1
- Configure
iwd
to usesystemd-resolved
for DNS resolution:
# /etc/iwd/main.conf
[Network]
NameResolvingService=systemd
- Point
systemd-resolved
as the DNS server in/etc/resolv.conf
# by default, /etc/resolv.conf is an empty file generated by NetworkManager
# so link the default
sudo ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
- Configure
systemd-resolved
to use gateway as the DNS server
# /etc/systemd/resolved.conf.d/default_dns.conf
[Resolve]
DNS=192.168.1.1
- Restart the services:
sudo systemctl enable --now systemd-resolved
sudo systemctl enable --now dhcpcd
sudo systemctl enable --now iwd
-
Connect to wifi using
iwctl
-
Make sure an IP address is assigned by
ip route
$ ip route
default via 192.168.1.1 dev wlan1 src 192.168.1.111 metric 305
192.168.1.0/24 dev wlan1 proto dhcp scope link src 192.168.1.111 metric 305
- Make sure DNS resolution is working by
resolvectl dns
$ resolvectl dns
Global: 192.168.1.1
Link 2 (enP4p65s0):
Link 3 (enP3p49s0):
Link 4 (wlan0):
Link 5 (wlan1):